home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 27 / 027.d81 / t.prebase boot < prev    next >
Text File  |  2022-08-26  |  6KB  |  392 lines

  1.  
  2.  
  3.               PREBASE
  4.                 by
  5.           Michael Leidel
  6.  
  7.  
  8. COMMODORE POWER/PLAY MAGAZINE
  9. August/September, 1986
  10.  
  11. **************************************
  12. NOTE: You must copy PREBASE, PASS2,
  13. and PREBASE BOOT to another disk
  14. before using this program.
  15. **************************************
  16.  
  17.  
  18. THE BIG PICTURE......
  19.  
  20.   If you've been used to writing
  21.  
  22. programs in languages like FORTRAN and
  23.  
  24. Pascal, PREBASE might make writing
  25.  
  26. BASIC programs easier for you. PREBASE
  27.  
  28. is a BASIC preprocessor that allows
  29.  
  30. you to write programs that use
  31.  
  32. structured control keywords like
  33.  
  34. WHILE-ENDWHILE, LOOP-ENDLOOP, or
  35.  
  36. LOOP-UNTIL that you've known from
  37.  
  38. other high-level languages.
  39.  
  40.  
  41.   PREBASE also allows the use of
  42.  
  43. English labels for branching instead
  44.  
  45. of line numbers, provides a directive
  46.  
  47. for including prewritten library
  48.  
  49. routines, and removes all REM
  50.  
  51. statements and extra spaces.
  52.  
  53.  
  54.   Once you have created a PREBASE
  55.  
  56. program file, Leidlel's two programs
  57.  
  58. ("PREBASE" and "PASS 2") will convert
  59.  
  60. the PREBASE source file to a normal
  61.  
  62. BASIC program.
  63.  
  64.  
  65.    We have included a sample PREBASE
  66.  
  67. program, "PREBASE TEST". To see it,
  68.  
  69. run PREBASE, and enter its name as the
  70.  
  71. program you want converted.
  72.  
  73.  
  74. WRITING PROGRAMS IN PREBASE
  75.  
  76.   Writing PREBASE programs is similar
  77.  
  78. to writing BASIC programs-- there are
  79.  
  80. only a few more rules to keep in mind.
  81.  
  82.  
  83. -- Line numbers should only be used
  84.  
  85. for sequencing lines, never after a
  86.  
  87. THEN, GOTO, or GOSUB.  Instead,
  88.  
  89. English labels should follow a GOTO or
  90.  
  91. GOSUB; however, labels should never
  92.  
  93. follow a THEN, although other BASIC
  94.  
  95. statements may.
  96.  
  97.  
  98. -- The target label should be the only
  99.  
  100. entry on the line.  It can be composed
  101.  
  102. of any combination of regular or
  103.  
  104. special characters and must be unique.
  105.  
  106. Resequencing line numbers will not
  107.  
  108. affect program control logic.
  109.  
  110.  
  111. -- Nothing must come before or after a
  112.  
  113. structured control construct on a
  114.  
  115. line.  The conditional following WHILE
  116.  
  117. or UNTIL must be preceded by one
  118.  
  119. space; nothing must follow the
  120.  
  121. conditional.
  122.  
  123.  
  124. -- Nesting may not exceed ten levels.
  125.  
  126. WHILE-ENDWHILE provides a condition
  127.  
  128. check at the beginning of a loop,
  129.  
  130. LOOP-UNTIL a condition check at the
  131.  
  132. end of a loop.  LOOP-ENDLOOP provides
  133.  
  134. a closed loop that must be exited by a
  135.  
  136. GOTO.
  137.  
  138.  
  139. -- PREBASE will merge in other PREBASE
  140.  
  141. files during its processing cycle.  To
  142.  
  143. use this "include" directive feature,
  144.  
  145. enclose the name in quotes and then in
  146.  
  147. square brackets.  For example,
  148.  
  149.  
  150. 100 ["filename"]
  151.  
  152.  
  153. will merge in the program file at line
  154.  
  155. 100 of the program using this
  156.  
  157. directive.
  158.  
  159.  
  160.   Nothing else may precede or follow
  161.  
  162. this directive on a line.  The file
  163.  
  164. used in the directive cannot itself
  165.  
  166. contain a directive of this type.
  167.  
  168.  
  169. -- Any line that is not a label,
  170.  
  171. structured control construct,
  172.  
  173. "include" directive, or REM statement
  174.  
  175. must begin with a period.  This
  176.  
  177. distinguishes a regular line from a
  178.  
  179. line needing special attention.
  180.  
  181.  
  182. -- A shifted space may be used instead
  183.  
  184. of a period to begin a regular line.
  185.  
  186. However, if you re-edit a line, the
  187.  
  188. shifted space will be removed.  Each
  189.  
  190. time the line is edited, the space
  191.  
  192. must be replaced.  A line beginning
  193.  
  194. with a period does not require this
  195.  
  196. attention.
  197.  
  198.  
  199. -- In the translation process, PREBASE
  200.  
  201. removes all REM statements and extra
  202.  
  203. spaces, converts all structured
  204.  
  205. constructs into regular BASIC
  206.  
  207. statements, makes branch labels
  208.  
  209. correspond with line numbers, and
  210.  
  211. integrates library routines that were
  212.  
  213. merged into a normal BASIC file.  The
  214.  
  215. translated program is written to the
  216.  
  217. disk with the name of the original
  218.  
  219. PREBASE file plus a ".BAS" extention
  220.  
  221. that marks it as a file that was once
  222.  
  223. a PREBASE file.
  224.  
  225.  
  226. -- PREBASE will not check normal BASIC
  227.  
  228. syntax or logic errors, but will
  229.  
  230. indicate certain errors relevant to
  231.  
  232. its special features.  If these kinds
  233.  
  234. of syntax errors are found, the errors
  235.  
  236. are listed and the final program is
  237.  
  238. not produced.
  239.  
  240.  
  241. USING PREBASE
  242.  
  243.   The first of the two programs,
  244.  
  245. "PREBASE" requests the date, the name
  246.  
  247. of the PREBASE program to be
  248.  
  249. translated, its beginning line number,
  250.  
  251. and the increment for the BASIC output
  252.  
  253. file.  It then parses through both the
  254.  
  255. PREBASE source file and any "included"
  256.  
  257. library files to make a file called
  258.  
  259. SYMTBL on disk.
  260.  
  261.  
  262. -- If you have the same name for two
  263.  
  264. different branch labels, you will get
  265.  
  266. a DUPLICATE LABEL error, and the
  267.  
  268. program will not execute the second
  269.  
  270. phase.  To fix, change one of the
  271.  
  272. labels.
  273.  
  274.  
  275.   The second part of the program,
  276.  
  277. PASS 2, uses the information in the
  278.  
  279. SYMTBL file to construct a normal
  280.  
  281. BASIC program.  The size of the
  282.  
  283. BASIC program will depend on how many
  284.  
  285. REM statements and spaces were removed
  286.  
  287. and how many "include" directives were
  288.  
  289. used.
  290.  
  291.  
  292.   If PASS 2 encounters errors, they,
  293.  
  294. along with the line at which they
  295.  
  296. occur, are displayed at the end of
  297.  
  298. processing and the BASIC program is
  299.  
  300. not created.  If it finds ten errors,
  301.  
  302. PASS 2 will stop at that point and
  303.  
  304. list them.
  305.  
  306.  
  307. POSSIBLE ERRORS
  308.  
  309. -- Incorrect formation of a construct
  310.    or label:
  311.  
  312.  
  313. LOOP ERROR
  314.  
  315. ENDLOOP ERROR
  316.  
  317. INVALID LABEL
  318.  
  319. UNTIL ERROR
  320.  
  321. ENDWHILE ERROR
  322.  
  323.  
  324. -- Missing part of a structured
  325.    construct:
  326.  
  327.  
  328. NO MATCHING LOOP
  329.  
  330. MISSING LOOP
  331.  
  332. NO MATCHING ENDWHILE
  333.  
  334. NO MATCHING WHILE
  335.  
  336.  
  337. -- Reference to a nonexistent label:
  338.  
  339. UNDEF LABEL
  340.  
  341.  
  342.   PASS 2 may crash if a line does not
  343.  
  344. begin with a REM, a structured
  345.  
  346. construct, an "include" directive, or
  347.  
  348. a period.  If this happens and you
  349.  
  350. want to examine the error list, GOTO
  351.  
  352. 8020.
  353.  
  354.  
  355.   Examining the SYMTBL file is also
  356.  
  357. helpful.  To do this, type in
  358.  
  359. immediate mode:
  360.  
  361.  
  362. FORX=1TOLC:?LBL$(X),NUM$(X):NEXT
  363.  
  364.  
  365.   The last thing PASS 2 does is create
  366.  
  367. two special REM statements as the last
  368.  
  369. two lines of the new BASIC program.
  370.  
  371. The first REM contains the name of the
  372.  
  373. program and the date.  The second REM
  374.  
  375. contains the ID string coded into
  376.  
  377. line 5 of the PASS 2 program.  These
  378.  
  379. REMs will have invalid line numbers so
  380.  
  381. they cannot be deleted from the
  382.  
  383. program.
  384.  
  385.  
  386. DISK FILES USED:
  387.  
  388. PREBASE           PREBASE TEST
  389. PASS 2
  390.  
  391. -----------< end of text >------------
  392.